<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2">
<meta name="theme-color" content="#222">
<meta name="generator" content="Hexo 5.2.0">
  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png">
  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png">
  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png">
  <link rel="mask-icon" href="/images/logo.svg" color="#222">

<link rel="stylesheet" href="/css/main.css">


<link rel="stylesheet" href="/lib/font-awesome/css/all.min.css">
  <link rel="stylesheet" href="/lib/pace/pace-theme-minimal.min.css">
  <script src="/lib/pace/pace.min.js"></script>

<script id="hexo-configurations">
    var NexT = window.NexT || {};
    var CONFIG = {"hostname":"sekla.cn","root":"/","scheme":"Muse","version":"7.8.0","exturl":false,"sidebar":{"position":"right","display":"post","padding":18,"offset":12,"onmobile":false},"copycode":{"enable":false,"show_result":false,"style":null},"back2top":{"enable":true,"sidebar":false,"scrollpercent":false},"bookmark":{"enable":false,"color":"#222","save":"auto"},"fancybox":false,"mediumzoom":false,"lazyload":false,"pangu":false,"comments":{"style":"tabs","active":"valine","storage":true,"lazyload":false,"nav":null},"algolia":{"hits":{"per_page":10},"labels":{"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}},"localsearch":{"enable":false,"trigger":"auto","top_n_per_article":1,"unescape":false,"preload":false},"motion":{"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},"path":"search.xml"};
  </script>

  <meta name="description" content="python语法的快速学习，简单概括python语言中的语法特性与不同规则。 字符串处理字符串索引python中字符串字符数组索引可以从0开始，与此同时还有一个反向递减序号，从-1开始递减。 字符串的切片ep： String[M:N] 以上语句代表对字符串String切片，从字符数组索引M起，直到N结束，若M或N缺失，则代表从开头或从结尾。 String[M:N:K] 以上语句多了第三个参数，代表">
<meta property="og:type" content="article">
<meta property="og:title" content="Python学习之路(1)-语法不同">
<meta property="og:url" content="http://sekla.cn/2021/09/20/way-to-python/index.html">
<meta property="og:site_name" content="Sekla&#39;s Blog">
<meta property="og:description" content="python语法的快速学习，简单概括python语言中的语法特性与不同规则。 字符串处理字符串索引python中字符串字符数组索引可以从0开始，与此同时还有一个反向递减序号，从-1开始递减。 字符串的切片ep： String[M:N] 以上语句代表对字符串String切片，从字符数组索引M起，直到N结束，若M或N缺失，则代表从开头或从结尾。 String[M:N:K] 以上语句多了第三个参数，代表">
<meta property="og:locale" content="zh_CN">
<meta property="article:published_time" content="2021-09-20T07:00:00.000Z">
<meta property="article:modified_time" content="2021-09-24T04:23:49.957Z">
<meta property="article:author" content="Sekla">
<meta property="article:tag" content="Python">
<meta name="twitter:card" content="summary">

<link rel="canonical" href="http://sekla.cn/2021/09/20/way-to-python/">


<script id="page-configurations">
  // https://hexo.io/docs/variables.html
  CONFIG.page = {
    sidebar: "",
    isHome : false,
    isPost : true,
    lang   : 'zh-CN'
  };
</script>

  <title>Python学习之路(1)-语法不同 | Sekla's Blog</title>
  






  <noscript>
  <style>
  .use-motion .brand,
  .use-motion .menu-item,
  .sidebar-inner,
  .use-motion .post-block,
  .use-motion .pagination,
  .use-motion .comments,
  .use-motion .post-header,
  .use-motion .post-body,
  .use-motion .collection-header { opacity: initial; }

  .use-motion .site-title,
  .use-motion .site-subtitle {
    opacity: initial;
    top: initial;
  }

  .use-motion .logo-line-before i { left: initial; }
  .use-motion .logo-line-after i { right: initial; }
  </style>
</noscript>

  <script type="text/javascript" src="/js/my_js/clicklove.js"></script>
<!-- hexo injector head_end start -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.12.0/dist/katex.min.css">

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/hexo-math@4.0.0/dist/style.css">
<!-- hexo injector head_end end --></head>

<body itemscope itemtype="http://schema.org/WebPage">
  <div class="container use-motion">
    <div class="headband"></div>

    <header class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-container">
  <div class="site-nav-toggle">
    <div class="toggle" aria-label="切换导航栏">
      <span class="toggle-line toggle-line-first"></span>
      <span class="toggle-line toggle-line-middle"></span>
      <span class="toggle-line toggle-line-last"></span>
    </div>
  </div>

  <div class="site-meta">

    <a href="/" class="brand" rel="start">
      <span class="logo-line-before"><i></i></span>
      <h1 class="site-title">Sekla's Blog</h1>
      <span class="logo-line-after"><i></i></span>
    </a>
      <p class="site-subtitle" itemprop="description">Keep Learning Keep Doing</p>
  </div>

  <div class="site-nav-right">
    <div class="toggle popup-trigger">
    </div>
  </div>
</div>




<nav class="site-nav">
  <ul id="menu" class="main-menu menu">
        <li class="menu-item menu-item-home">

    <a href="/" rel="section"><i class="fa fa-home fa-fw"></i>首页</a>

  </li>
        <li class="menu-item menu-item-about">

    <a href="/about/" rel="section"><i class="fa fa-user fa-fw"></i>关于</a>

  </li>
        <li class="menu-item menu-item-tags">

    <a href="/tags/" rel="section"><i class="fa fa-tags fa-fw"></i>标签<span class="badge">14</span></a>

  </li>
        <li class="menu-item menu-item-categories">

    <a href="/categories/" rel="section"><i class="fa fa-th fa-fw"></i>分类<span class="badge">23</span></a>

  </li>
        <li class="menu-item menu-item-archives">

    <a href="/archives/" rel="section"><i class="fa fa-archive fa-fw"></i>归档<span class="badge">100</span></a>

  </li>
  </ul>
</nav>




</div>
    </header>

    
  <div class="back-to-top">
    <i class="fa fa-arrow-up"></i>
    <span>0%</span>
  </div>
  <div class="reading-progress-bar"></div>


    <main class="main">
      <div class="main-inner">
        <div class="content-wrap">
          

          <div class="content post posts-expand">
            

    
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://sekla.cn/2021/09/20/way-to-python/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.jpg">
      <meta itemprop="name" content="Sekla">
      <meta itemprop="description" content="Sekla">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="Sekla's Blog">
    </span>
      <header class="post-header">
        <h1 class="post-title" itemprop="name headline">
          Python学习之路(1)-语法不同
        </h1>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-calendar"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2021-09-20 15:00:00" itemprop="dateCreated datePublished" datetime="2021-09-20T15:00:00+08:00">2021-09-20</time>
            </span>
              <span class="post-meta-item">
                <span class="post-meta-item-icon">
                  <i class="far fa-calendar-check"></i>
                </span>
                <span class="post-meta-item-text">更新于</span>
                <time title="修改时间：2021-09-24 12:23:49" itemprop="dateModified" datetime="2021-09-24T12:23:49+08:00">2021-09-24</time>
              </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-folder"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/Python/" itemprop="url" rel="index"><span itemprop="name">Python</span></a>
                </span>
            </span>

          
            <span class="post-meta-item" title="阅读次数" id="busuanzi_container_page_pv" style="display: none;">
              <span class="post-meta-item-icon">
                <i class="fa fa-eye"></i>
              </span>
              <span class="post-meta-item-text">阅读次数：</span>
              <span id="busuanzi_value_page_pv"></span>
            </span><br>
            <span class="post-meta-item" title="本文字数">
              <span class="post-meta-item-icon">
                <i class="far fa-file-word"></i>
              </span>
                <span class="post-meta-item-text">本文字数：</span>
              <span>1.6k</span>
            </span>
            <span class="post-meta-item" title="阅读时长">
              <span class="post-meta-item-icon">
                <i class="far fa-clock"></i>
              </span>
                <span class="post-meta-item-text">阅读时长 &asymp;</span>
              <span>1 分钟</span>
            </span>

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
        <p>python语法的快速学习，简单概括python语言中的语法特性与不同规则。</p>
<h2 id="字符串处理"><a href="#字符串处理" class="headerlink" title="字符串处理"></a>字符串处理</h2><h3 id="字符串索引"><a href="#字符串索引" class="headerlink" title="字符串索引"></a>字符串索引</h3><p>python中字符串字符数组索引可以从0开始，与此同时还有一个反向递减序号，从-1开始递减。</p>
<h3 id="字符串的切片"><a href="#字符串的切片" class="headerlink" title="字符串的切片"></a>字符串的切片</h3><p>ep：</p>
<p><strong>String[M:N]</strong></p>
<p>以上语句代表对字符串String切片，从字符数组索引M起，直到N结束，若M或N缺失，则代表从开头或从结尾。</p>
<p><strong>String[M:N:K]</strong></p>
<p>以上语句多了第三个参数，代表切片处理步长为K，从字符数组索引M开始。</p>
<p>如果-1，则代表步长为-1，按照索引逆序规则，即为逆序处理字符串。</p>
<a id="more"></a>

<h3 id="字符串操作符"><a href="#字符串操作符" class="headerlink" title="字符串操作符"></a>字符串操作符</h3><p>除了常规的字符串操作符，添加了：</p>
<h4 id="str-n"><a href="#str-n" class="headerlink" title="str*n"></a>str*n</h4><p>复制n次str字符串。</p>
<h4 id="str1-in-str2"><a href="#str1-in-str2" class="headerlink" title="str1 in str2"></a>str1 in str2</h4><p>查询str1是否是str2的子串，返回一个布尔值。</p>
<h3 id="字符串函数"><a href="#字符串函数" class="headerlink" title="字符串函数"></a>字符串函数</h3><h3 id="str-p-和eval-p"><a href="#str-p-和eval-p" class="headerlink" title="str(p)和eval(p)"></a>str(p)和eval(p)</h3><p>互为字符串相反的操作，str()函数操作将字符串添加引号，eval则相反。</p>
<h3 id="chr-p-和ord-p"><a href="#chr-p-和ord-p" class="headerlink" title="chr(p)和ord(p)"></a>chr(p)和ord(p)</h3><p>同为互为相反的操作，chr将unicode返回对应字符，ord将字符返回为对应Unicode编码。</p>
<h3 id="字符串处理方法"><a href="#字符串处理方法" class="headerlink" title="字符串处理方法"></a>字符串处理方法</h3><p>字符串本身为对象，可以调用python自身的基础处理方法。</p>
<h4 id="str-lower-与str-upper"><a href="#str-lower-与str-upper" class="headerlink" title="str.lower()与str.upper()"></a>str.lower()与str.upper()</h4><p>返回字符串副本，全部字符小写或变成大写。</p>
<h4 id="str-split-sep-None"><a href="#str-split-sep-None" class="headerlink" title="str.split(sep=None)"></a>str.split(sep=None)</h4><p>返回一个列表，根据参数指定来对字符串进行分割，返回分割后的独立字符串列表。</p>
<h4 id="str-count-sub"><a href="#str-count-sub" class="headerlink" title="str.count(sub)"></a>str.count(sub)</h4><p>返回子串sub在字符串str中出现的次数。</p>
<h4 id="str-replace-old-new"><a href="#str-replace-old-new" class="headerlink" title="str.replace(old,new)"></a>str.replace(old,new)</h4><p>返回字符串的str副本，将字符串old子串替换为new。</p>
<h4 id="str-center-width-fillchar"><a href="#str-center-width-fillchar" class="headerlink" title="str.center(width[,fillchar])"></a>str.center(width[,fillchar])</h4><p>字符串str根据宽度width居中，fillchar为可选参数，字符串长度不足需要通过fillchar参数填充。</p>
<h4 id="str-strip-chars"><a href="#str-strip-chars" class="headerlink" title="str.strip(chars)"></a>str.strip(chars)</h4><p>从str中去除在其左侧或者右侧chars中列出的字符。</p>
<h4 id="str-join-iter"><a href="#str-join-iter" class="headerlink" title="str.join(iter)"></a>str.join(iter)</h4><p>在iter变量除最后一个元素以外每个元素之后增加一个如str=”,”，即用逗号分隔字符串。</p>
<h3 id="格式化输出"><a href="#格式化输出" class="headerlink" title="格式化输出"></a>格式化输出</h3><p>使用format()方法。</p>
<p>python中用{}表示的称作槽。</p>
<p>在槽的内部，对格式化方法进行配置，{&lt;参数序号&gt;:&lt;格·式控制标记&gt;}</p>
<h4 id="填充，对其与宽度"><a href="#填充，对其与宽度" class="headerlink" title="填充，对其与宽度"></a>填充，对其与宽度</h4><p>填充代表用于填充的单个字符，&lt;左对齐，&gt;右对齐，^居中对其，宽度为槽设定的输出宽度。</p>
<h3 id="，-类型"><a href="#，-类型" class="headerlink" title="， . 类型-"></a>， . 类型-</h3><p>数字的千位分隔符，浮点数小数精度或者字符串最大输出长度，数字类型。</p>
<h2 id="异常处理"><a href="#异常处理" class="headerlink" title="异常处理"></a>异常处理</h2><p>try:</p>
<p>except statement:</p>
<p>以上语句首先执行try语句，若有异常出现则执行except语句，statement为python内部定义的异常定义类型。</p>
<p>同样：</p>
<p>else：</p>
<p>语句3</p>
<p>finally：</p>
<p>语句4，语句3为不发生异常进行处理，语句4是必须处理的。</p>
<h2 id="循环"><a href="#循环" class="headerlink" title="循环"></a>循环</h2><p>for in除了执行循环之外，可以在之后添加else语句，若循坏没有通过break结束，可以执行else语句后的内容。</p>
<h2 id="random库"><a href="#random库" class="headerlink" title="random库"></a>random库</h2><p>python中产生随机数的库，一样的，需要随机数种子与产生随机数，不调用seed()函数会默认用操作系统时间作为参数产生随机数种子，random()函数产生随机数，</p>
<h3 id="扩展随机数"><a href="#扩展随机数" class="headerlink" title="扩展随机数"></a>扩展随机数</h3><h4 id="randint-x，y"><a href="#randint-x，y" class="headerlink" title="randint(x，y)"></a>randint(x，y)</h4><p>产生x，y之间的随机整数。</p>
<h4 id="randrange-m-n-k"><a href="#randrange-m-n-k" class="headerlink" title="randrange(m,n[,k])"></a>randrange(m,n[,k])</h4><p>生成[m,n)之间以k为步长的随机整数。</p>
<h4 id="getrandbits-k"><a href="#getrandbits-k" class="headerlink" title="getrandbits(k)"></a>getrandbits(k)</h4><p>生成一个k比特长的随机整数。</p>
<h4 id="uniform-a-b"><a href="#uniform-a-b" class="headerlink" title="uniform(a,b)"></a>uniform(a,b)</h4><p>生成a到b之间的随机小数，精度为16位。</p>
<h4 id="choice-seq"><a href="#choice-seq" class="headerlink" title="choice(seq)"></a>choice(seq)</h4><p>从序列seq中随机选择一个元素。</p>
<h4 id="shuffle-seq"><a href="#shuffle-seq" class="headerlink" title="shuffle(seq)"></a>shuffle(seq)</h4><p>将序列seq中元素随机排列并返回。</p>
<h2 id="函数"><a href="#函数" class="headerlink" title="函数"></a>函数</h2><p>python中定义函数参数时，可以定义可选参数，可以在定义函数时，给出可变参数值，若调用函数没有给出可变参数，将使用定义时的默认值。</p>
<p>定义函数时还可以定义可变参数，确定参数在前，*p来表示，可变参数可以在调用时给出任意个参数。</p>
<h2 id="lambda函数"><a href="#lambda函数" class="headerlink" title="lambda函数"></a>lambda函数</h2><p>python中的匿名函数，使用lambda保留字定义：</p>
<p><strong>函数名= lambda 参数：表达式</strong></p>

    </div>
    
    
    

      <footer class="post-footer">
          
          <div class="post-tags">
              <a href="/tags/Python/" rel="tag"><i class="fa fa-tag"></i> Python</a>
          </div>

        


        
    <div class="post-nav">
      <div class="post-nav-item">
    <a href="/2021/09/17/%E5%8D%95%E7%89%87%E6%9C%BA%E6%9C%80%E7%BB%88%E5%AE%9E%E9%AA%8C/" rel="prev" title="单片机最终实验设计与BSP开发">
      <i class="fa fa-chevron-left"></i> 单片机最终实验设计与BSP开发
    </a></div>
      <div class="post-nav-item">
    <a href="/2021/09/21/wayToPythonOS/" rel="next" title="Python学习之路(2)-OS库常用总结">
      Python学习之路(2)-OS库常用总结 <i class="fa fa-chevron-right"></i>
    </a></div>
    </div>
      </footer>
    
  </article>
  
  
  



          </div>
          

<script>
  window.addEventListener('tabs:register', () => {
    let { activeClass } = CONFIG.comments;
    if (CONFIG.comments.storage) {
      activeClass = localStorage.getItem('comments_active') || activeClass;
    }
    if (activeClass) {
      let activeTab = document.querySelector(`a[href="#comment-${activeClass}"]`);
      if (activeTab) {
        activeTab.click();
      }
    }
  });
  if (CONFIG.comments.storage) {
    window.addEventListener('tabs:click', event => {
      if (!event.target.matches('.tabs-comment .tab-content .tab-pane')) return;
      let commentClass = event.target.classList[1];
      localStorage.setItem('comments_active', commentClass);
    });
  }
</script>

        </div>
          
  
  <div class="toggle sidebar-toggle">
    <span class="toggle-line toggle-line-first"></span>
    <span class="toggle-line toggle-line-middle"></span>
    <span class="toggle-line toggle-line-last"></span>
  </div>

  <aside class="sidebar">
    <div class="sidebar-inner">

      <ul class="sidebar-nav motion-element">
        <li class="sidebar-nav-toc">
          文章目录
        </li>
        <li class="sidebar-nav-overview">
          站点概览
        </li>
      </ul>

      <!--noindex-->
      <div class="post-toc-wrap sidebar-panel">
          <div class="post-toc motion-element"><ol class="nav"><li class="nav-item nav-level-2"><a class="nav-link" href="#%E5%AD%97%E7%AC%A6%E4%B8%B2%E5%A4%84%E7%90%86"><span class="nav-number">1.</span> <span class="nav-text">字符串处理</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#%E5%AD%97%E7%AC%A6%E4%B8%B2%E7%B4%A2%E5%BC%95"><span class="nav-number">1.1.</span> <span class="nav-text">字符串索引</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E5%AD%97%E7%AC%A6%E4%B8%B2%E7%9A%84%E5%88%87%E7%89%87"><span class="nav-number">1.2.</span> <span class="nav-text">字符串的切片</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E5%AD%97%E7%AC%A6%E4%B8%B2%E6%93%8D%E4%BD%9C%E7%AC%A6"><span class="nav-number">1.3.</span> <span class="nav-text">字符串操作符</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#str-n"><span class="nav-number">1.3.1.</span> <span class="nav-text">str*n</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#str1-in-str2"><span class="nav-number">1.3.2.</span> <span class="nav-text">str1 in str2</span></a></li></ol></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E5%AD%97%E7%AC%A6%E4%B8%B2%E5%87%BD%E6%95%B0"><span class="nav-number">1.4.</span> <span class="nav-text">字符串函数</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#str-p-%E5%92%8Ceval-p"><span class="nav-number">1.5.</span> <span class="nav-text">str(p)和eval(p)</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#chr-p-%E5%92%8Cord-p"><span class="nav-number">1.6.</span> <span class="nav-text">chr(p)和ord(p)</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E5%AD%97%E7%AC%A6%E4%B8%B2%E5%A4%84%E7%90%86%E6%96%B9%E6%B3%95"><span class="nav-number">1.7.</span> <span class="nav-text">字符串处理方法</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#str-lower-%E4%B8%8Estr-upper"><span class="nav-number">1.7.1.</span> <span class="nav-text">str.lower()与str.upper()</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#str-split-sep-None"><span class="nav-number">1.7.2.</span> <span class="nav-text">str.split(sep&#x3D;None)</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#str-count-sub"><span class="nav-number">1.7.3.</span> <span class="nav-text">str.count(sub)</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#str-replace-old-new"><span class="nav-number">1.7.4.</span> <span class="nav-text">str.replace(old,new)</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#str-center-width-fillchar"><span class="nav-number">1.7.5.</span> <span class="nav-text">str.center(width[,fillchar])</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#str-strip-chars"><span class="nav-number">1.7.6.</span> <span class="nav-text">str.strip(chars)</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#str-join-iter"><span class="nav-number">1.7.7.</span> <span class="nav-text">str.join(iter)</span></a></li></ol></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E6%A0%BC%E5%BC%8F%E5%8C%96%E8%BE%93%E5%87%BA"><span class="nav-number">1.8.</span> <span class="nav-text">格式化输出</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#%E5%A1%AB%E5%85%85%EF%BC%8C%E5%AF%B9%E5%85%B6%E4%B8%8E%E5%AE%BD%E5%BA%A6"><span class="nav-number">1.8.1.</span> <span class="nav-text">填充，对其与宽度</span></a></li></ol></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%EF%BC%8C-%E7%B1%BB%E5%9E%8B"><span class="nav-number">1.9.</span> <span class="nav-text">， . 类型-</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E5%BC%82%E5%B8%B8%E5%A4%84%E7%90%86"><span class="nav-number">2.</span> <span class="nav-text">异常处理</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E5%BE%AA%E7%8E%AF"><span class="nav-number">3.</span> <span class="nav-text">循环</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#random%E5%BA%93"><span class="nav-number">4.</span> <span class="nav-text">random库</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#%E6%89%A9%E5%B1%95%E9%9A%8F%E6%9C%BA%E6%95%B0"><span class="nav-number">4.1.</span> <span class="nav-text">扩展随机数</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#randint-x%EF%BC%8Cy"><span class="nav-number">4.1.1.</span> <span class="nav-text">randint(x，y)</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#randrange-m-n-k"><span class="nav-number">4.1.2.</span> <span class="nav-text">randrange(m,n[,k])</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#getrandbits-k"><span class="nav-number">4.1.3.</span> <span class="nav-text">getrandbits(k)</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#uniform-a-b"><span class="nav-number">4.1.4.</span> <span class="nav-text">uniform(a,b)</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#choice-seq"><span class="nav-number">4.1.5.</span> <span class="nav-text">choice(seq)</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#shuffle-seq"><span class="nav-number">4.1.6.</span> <span class="nav-text">shuffle(seq)</span></a></li></ol></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E5%87%BD%E6%95%B0"><span class="nav-number">5.</span> <span class="nav-text">函数</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#lambda%E5%87%BD%E6%95%B0"><span class="nav-number">6.</span> <span class="nav-text">lambda函数</span></a></li></ol></div>
      </div>
      <!--/noindex-->

      <div class="site-overview-wrap sidebar-panel">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
    <img class="site-author-image" itemprop="image" alt="Sekla"
      src="/images/avatar.jpg">
  <p class="site-author-name" itemprop="name">Sekla</p>
  <div class="site-description" itemprop="description">Sekla</div>
</div>
<div class="site-state-wrap motion-element">
  <nav class="site-state">
      <div class="site-state-item site-state-posts">
          <a href="/archives/">
        
          <span class="site-state-item-count">100</span>
          <span class="site-state-item-name">日志</span>
        </a>
      </div>
      <div class="site-state-item site-state-categories">
            <a href="/categories/">
          
        <span class="site-state-item-count">23</span>
        <span class="site-state-item-name">分类</span></a>
      </div>
      <div class="site-state-item site-state-tags">
            <a href="/tags/">
          
        <span class="site-state-item-count">14</span>
        <span class="site-state-item-name">标签</span></a>
      </div>
  </nav>
</div>
  <div class="links-of-author motion-element">
      <span class="links-of-author-item">
        <a href="https://github.com/ShenTiao" title="GitHub → https:&#x2F;&#x2F;github.com&#x2F;ShenTiao" rel="noopener" target="_blank"><i class="fab fa-github fa-fw"></i>GitHub</a>
      </span>
      <span class="links-of-author-item">
        <a href="mailto:584892986@qq.com" title="E-Mail → mailto:584892986@qq.com" rel="noopener" target="_blank"><i class="fa fa-envelope fa-fw"></i>E-Mail</a>
      </span>
  </div>



      </div>

      <iframe frameborder="no" border="0" marginwidth="0" marginheight="0" width=330 height=86 src="//music.163.com/outchain/player?type=2&id=1416875904&auto=0&height=66"></iframe>
      
    </div>
  </aside>
  <div id="sidebar-dimmer"></div>


      </div>
    </main>

    <footer class="footer">
      <div class="footer-inner">
        

        

<div class="copyright">
  
  &copy; 
  <span itemprop="copyrightYear">2022</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">Sekla</span>
    <span class="post-meta-divider">|</span>
    <span class="post-meta-item-icon">
      <i class="fa fa-chart-area"></i>
    </span>
    <span title="站点总字数">288k</span>
    <span class="post-meta-divider">|</span>
    <span class="post-meta-item-icon">
      <i class="fa fa-coffee"></i>
    </span>
    <span title="站点阅读时长">4:22</span>
</div>
  <div class="powered-by">由 <a href="https://hexo.io/" class="theme-link" rel="noopener" target="_blank">Hexo</a> & <a href="https://muse.theme-next.org/" class="theme-link" rel="noopener" target="_blank">NexT.Muse</a> 强力驱动
  </div>

        
<div class="busuanzi-count">
  <script async src="https://busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>
    <span class="post-meta-item" id="busuanzi_container_site_uv" style="display: none;">
      <span class="post-meta-item-icon">
        <i class="fa fa-user"></i>
      </span>
      <span class="site-uv" title="总访客量">
        <span id="busuanzi_value_site_uv"></span>
      </span>
    </span>
    <span class="post-meta-divider">|</span>
    <span class="post-meta-item" id="busuanzi_container_site_pv" style="display: none;">
      <span class="post-meta-item-icon">
        <i class="fa fa-eye"></i>
      </span>
      <span class="site-pv" title="总访问量">
        <span id="busuanzi_value_site_pv"></span>
      </span>
    </span>
</div>








      </div>
    </footer>
  </div>

  
  <script size="300" alpha="0.6" zIndex="-1" src="/lib/canvas-ribbon/canvas-ribbon.js"></script>
  <script src="/lib/anime.min.js"></script>
  <script src="/lib/velocity/velocity.min.js"></script>
  <script src="/lib/velocity/velocity.ui.min.js"></script>

<script src="/js/utils.js"></script>

<script src="/js/motion.js"></script>


<script src="/js/schemes/muse.js"></script>


<script src="/js/next-boot.js"></script>




  















  

  
      

<script>
  if (typeof MathJax === 'undefined') {
    window.MathJax = {
      loader: {
        source: {
          '[tex]/amsCd': '[tex]/amscd',
          '[tex]/AMScd': '[tex]/amscd'
        }
      },
      tex: {
        inlineMath: {'[+]': [['$', '$']]},
        tags: 'ams'
      },
      options: {
        renderActions: {
          findScript: [10, doc => {
            document.querySelectorAll('script[type^="math/tex"]').forEach(node => {
              const display = !!node.type.match(/; *mode=display/);
              const math = new doc.options.MathItem(node.textContent, doc.inputJax[0], display);
              const text = document.createTextNode('');
              node.parentNode.replaceChild(text, node);
              math.start = {node: text, delim: '', n: 0};
              math.end = {node: text, delim: '', n: 0};
              doc.math.push(math);
            });
          }, '', false],
          insertedScript: [200, () => {
            document.querySelectorAll('mjx-container').forEach(node => {
              let target = node.parentNode;
              if (target.nodeName.toLowerCase() === 'li') {
                target.parentNode.classList.add('has-jax');
              }
            });
          }, '', false]
        }
      }
    };
    (function () {
      var script = document.createElement('script');
      script.src = '//cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js';
      script.defer = true;
      document.head.appendChild(script);
    })();
  } else {
    MathJax.startup.document.state(0);
    MathJax.texReset();
    MathJax.typeset();
  }
</script>

    

  

<script src="/live2dw/lib/L2Dwidget.min.js?094cbace49a39548bed64abff5988b05"></script><script>L2Dwidget.init({"pluginRootPath":"live2dw/","pluginJsPath":"lib/","pluginModelPath":"assets/","tagMode":false,"debug":false,"model":{"jsonPath":"/live2dw/assets/shizuku.model.json"},"display":{"position":"left","width":250,"height":500},"mobile":{"show":false},"react":{"opacity":0.9},"log":false});</script></body>
</html>

<script type="text/javascript" src="/js/src/love.js"></script>
